<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="68px" @submit.native.prevent>
      <el-form-item label="资产ID">
        <el-input v-model="queryParams.assetsIdCard" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list" border>
      <el-table-column label="资产ID" align="center" prop="assetsIdCard" />
      <el-table-column label="购入单价" align="center" prop="bulMoney">
        <template slot-scope="scope">
          {{ toMoney(scope.row.bulMoney) }}
        </template>
      </el-table-column>
      <el-table-column label="累计维修次数" align="center" prop="reportCount" />
      <el-table-column label="累计维修金额" align="center">
        <template slot-scope="scope">
          {{ toMoney(scope.row.repairOtherMoney + scope.row.repairMoney) }}
        </template>
      </el-table-column>
      <el-table-column label="累计折旧期数" align="center" prop="depreciationNumber">
        <template slot-scope="scope">
          {{ scope.row.depreciationNumber ? scope.row.depreciationNumber : 0 }}
        </template>
      </el-table-column>
      <el-table-column label="累计折旧金额" align="center" prop="depreciationMoney">
        <template slot-scope="scope">
          {{ toMoney(scope.row.depreciationMoney) }}
        </template>
      </el-table-column>
      <el-table-column label="累计增值期数" align="center" prop="addedNumber">
        <template slot-scope="scope">
          {{ scope.row.addedNumber ? scope.row.addedNumber : 0 }}
        </template>
      </el-table-column>
      <el-table-column label="累计增值金额" align="center" prop="addedMoney">
        <template slot-scope="scope">
          {{ toMoney(scope.row.addedMoney) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleView(scope.row)">查看明细</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 资产明细 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <assets-details-group-project v-if="open" :assetsIdCard="assetsIdCard"></assets-details-group-project>
    </el-dialog>

  </div>
</template>

<script>
import assetsDetailsGroupProject from './assetsDetailsGroupProject.vue';
import { selectAssetsDetailsList } from '@/api/cld/assets'
export default {
  name: "assetsViewDetails",
  props: {
    assetsId: {
      type: String
    },
    assetsName: {
      typeof: String
    }
  },
  components: { assetsDetailsGroupProject },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 列表数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        assetsId: this.assetsId,
        assetsIdCard: null
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      assetsIdCard: null
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      selectAssetsDetailsList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.list = response.data;
        this.loading = false;
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 查看明细
    handleView(row) {
      this.assetsIdCard = row.assetsIdCard;
      this.title = this.assetsName + '-' + row.assetsIdCard + '明细';
      this.open = true;
    }
  }
};
</script>
<style scoped>
.el-select {
  width: 100%;
}
</style>
